home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Mousebroken 1.0.1 / source / Mousebroken source ƒ / NMRP code / NMRP.c next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  2.8 KB  |  99 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        NMRP.c
  4.  
  5. Purpose:    This module handles cleaning up after a Notification
  6.             Manager note has been displayed.
  7.             
  8. This code was originally written by Dave Blumenthal, 12/92
  9. Modified for use in Mousebroken by Mark Pilgrim, 12/93
  10.  
  11.  
  12. Mousebroken -=- your computer isn't truly broken until it's mousebroken
  13. Copyright (C) 1993 Mark Pilgrim
  14.  
  15. This program is free software; you can redistribute it and/or modify
  16. it under the terms of the GNU General Public License as published by
  17. the Free Software Foundation; either version 2 of the License, or
  18. (at your option) any later version.
  19.  
  20. This program is distributed in the hope that it will be useful,
  21. but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23. GNU General Public License for more details.
  24.  
  25. You should have received a copy of the GNU General Public License
  26. along with this program in a file named "GNU General Public License".
  27. If not, write to the Free Software Foundation, 675 Mass Ave,
  28. Cambridge, MA 02139, USA.
  29.  
  30. \**********************************************************************/
  31.  
  32. extern long        ToolScratch : 0x09CE;
  33.  
  34. void FlushCodeCache(void) = 0xA0BD;
  35.  
  36. #define            _HwPriv            0xA198
  37. #define            _CacheFlush        0xA0BD
  38. #define            _Moof            0xA89F
  39.  
  40. pascal void main(NMRecPtr note)
  41. {
  42.     long            saveReturn;
  43.     Boolean            Caches040;
  44.     Boolean            Caches020;
  45.     
  46.     Caches040 = (GetOSTrapAddress(_HwPriv) != GetToolTrapAddress(_Moof));
  47.     Caches020 = (GetOSTrapAddress(_CacheFlush) != GetToolTrapAddress(_Moof));
  48.     
  49.     asm
  50.     {
  51.         move.l        note, a0
  52.         _NMRemove
  53.         
  54.         move.l        note, a0
  55.         move.l        OFFSET(NMRec, nmStr)(a0), a0
  56.         beq.s        @1
  57.         _DisposePtr
  58.         
  59. @1:        move.l        note, a0
  60.         _DisposePtr
  61.         
  62.         /* I don't like this - it uses low mem globals and assumes an     */
  63.         /* implicit link, not to mention that it's self-modifying code.   */
  64.         /* But, it seems to work.  Well, at least it compiles...          */
  65.         
  66.         /* ADDENDUM - this code assumes the following:                    */
  67.         /*  1) The compiler has put a LINK A6 at the start of the routine */
  68.         /*  2) The UNLK and RTS code at the end does not modify registers */
  69.         /*     D0 or A1, or ToolScratch                                   */
  70.         /*  3) _DisposeHandle does not modify register A1
  71.         /*  4) ToolScratch is not modified by any of the following traps: */
  72.         /*     _DisposeHandle, _RecoverHandle, _CacheFlush, and _HwPriv   */
  73.         
  74.         move.l        4(a6), saveReturn
  75.         move.l        #ToolScratch, a0
  76.         move.l        a0, 4(a6)
  77.         move.l        #0x2040A023, (a0)    ; movea.l    d0, a0 / _DisposeHandle
  78.         move.w        #0x4ED1, 4(a0)        ; jmp        (a1)
  79.     }
  80.     
  81.     if(Caches040)
  82.     {
  83.         FlushDataCache();
  84.         FlushInstructionCache();
  85.     }
  86.     else if(Caches020)
  87.     {
  88.         FlushCodeCache();
  89.     }
  90.     
  91.     asm
  92.     {
  93.         lea            main, a0
  94.         _RecoverHandle
  95.         move.l        a0, d0
  96.         move.l        saveReturn, a1
  97.     }
  98. }
  99.